from rest_framework.serializers import ModelSerializer
from rest_framework import serializers
from .models import *


class CateSer(ModelSerializer):
    class Meta:
        model = Cate
        fields = "__all__"


class Cate2Ser(ModelSerializer):
    cate3_list = serializers.SerializerMethodField()

    def get_cate3_list(self,obj):
        return CateSer(obj.sub_cate.all(),many=True).data

    class Meta:
        model = Cate
        fields = "__all__"
